Skip to content

top k parameter Chat API#547

Closed
soniyaLama0 wants to merge 6 commits into
param20h:devfrom
soniyaLama0:feature/top-k-parameter
Closed

top k parameter Chat API#547
soniyaLama0 wants to merge 6 commits into
param20h:devfrom
soniyaLama0:feature/top-k-parameter

Conversation

@soniyaLama0

Copy link
Copy Markdown
Contributor

## 📋 PR Checklist

Thank you for contributing to PDF-Assistant-RAG! 🎉
Please fill out this template before submitting. PRs without it filled in will be closed.


🔗 Related Issue

N/A

📝 What does this PR do?

This PR adds a configurable top-k retrieval parameter to the Chat API, allowing the user to dynamically adjust the number of context chunks retrieved during RAG queries.

Specifically, it:

  1. Adds a top_k parameter to the ChatRequest schema.
  2. Updates /ask and /ask/stream endpoints to pass the top_k value down to the retriever.
  3. Adds a "Sources count (Top-K)" slider in the Frontend Chat Settings menu to let users easily configure this value before asking questions.

🗂️ Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🔧 Refactor / code cleanup
  • 📝 Documentation update
  • 🎨 UI / styling change
  • ⚙️ CI / tooling / config change
  • 🧪 Tests

🧪 How was this tested?

  • Ran the backend locally (uvicorn app.main:app --reload)
  • Ran the frontend locally (npm run dev inside frontend/)
  • Tested the affected API endpoints manually
  • Added / updated tests

📸 Screenshots (if UI change)

image Screenshot 2026-06-10 101452

⚠️ Anything to flag for reviewers?

The default fallback for top_k remains unchanged (driven by backend settings) if the frontend does not explicitly provide a value.


✅ Self-Review Checklist

  • My branch is based on dev, not main
  • I have not added any secrets / API keys
  • I have not modified main branch or any HuggingFace deployment config
  • My code follows the existing style (no unnecessary formatting changes)
  • I have updated relevant docs / comments if needed

@soniyaLama0 soniyaLama0 requested a review from param20h as a code owner June 10, 2026 04:59
@soniyaLama0 soniyaLama0 force-pushed the feature/top-k-parameter branch from c250180 to a23561e Compare June 10, 2026 05:04
param20h
param20h previously approved these changes Jun 11, 2026
@param20h

Copy link
Copy Markdown
Owner

mergeeee conflicts

@soniyaLama0 soniyaLama0 requested a review from param20h June 12, 2026 06:25
param20h
param20h previously approved these changes Jun 16, 2026
param20h
param20h previously approved these changes Jun 16, 2026
param20h
param20h previously approved these changes Jun 16, 2026
@param20h

Copy link
Copy Markdown
Owner

✅ This PR has been merged directly into dev by maintainer.

@param20h param20h closed this Jun 28, 2026
@param20h param20h added level:intermediate +35 pts mentor:param20h Mentor for this PR gssoc:approved Approved for GSSoC base points (+50 pts) labels Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSoC base points (+50 pts) level:intermediate +35 pts mentor:param20h Mentor for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants